package com.hry.springbootmybatis.controller;

import com.hry.springbootmybatis.pojo.Book;
import com.hry.springbootmybatis.service.BookService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: HRYing
 * @Date:
 * @Description:
 */

@Controller
public class BookController {

    @Resource
    BookService bookService;


    @ResponseBody
    @GetMapping("/book/{id}")
    public Book getBookById(@PathVariable("id") Integer id) {

        Book book = bookService.selectById(id);
        System.out.println(book);
        return book;
    }

    @GetMapping("/say")
    public String hello(Model model) {
        model.addAttribute("data", "sayHello");
        return "index";
    }
}
